package com.njitzx.fileupload.controller;

import com.njitzx.fileupload.pojo.Comment;
import com.njitzx.fileupload.service.CommentService;
import com.njitzx.fileupload.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @PostMapping()
    public AjaxResult addComment(@RequestBody Comment comment) {
        commentService.addComment(comment);
        return AjaxResult.success("评论成功");
    }

    @GetMapping("/{id}")
    public AjaxResult getCommentById(@PathVariable("id") Integer id) {
        return AjaxResult.success(commentService.getCommentById(id));
    }

}
